﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SEO.Entity;
using SEO.Business;

public partial class SetConfig : AdminPage
{
    /// <summary>
    /// 设置配置信息
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            InitData();
        }
    }

    /// <summary>
    /// 权限控制
    /// </summary>
    /// <returns></returns>
    public override long GetNeededFeatures()
    {
        return AdminFEATURE.SysConfig;
    }

    /// <summary>
    /// 初始化数据
    /// </summary>
    protected void InitData()
    {
        SysConfig info = Common.GetSysConfig();
        if (info != null)
        {
            txtBaiduPage.Text = info.BaiduPage.ToString();
            txtAccountDay.Text = info.AccountDay.ToString();
          //  txtBaiduDay.Text = info.BaiduDay.ToString();
            txtNewsFirstMomey.Text = info.NewsFirstMomey.ToString();
            txtNewsSecondMomey.Text = info.NewsSecondMomey.ToString();
            txtLinkFirstMomey.Text = info.LinkFirstMomey.ToString();
            txtLinkSecondMomey.Text = info.LinkSecondMomey.ToString();
            txtOurWebMomey.Text = info.OurWebMomey.ToString();
            txtLockNumber.Text = info.LockNumber.ToString();
        }
    }

    /// <summary>
    /// 提交操作
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        SysConfig Info = new SysConfig();
        Info.BaiduPage = Convert.ToInt32(txtBaiduPage.Text.Trim());
        Info.AccountDay = Convert.ToInt32(txtAccountDay.Text.Trim());
        Info.BaiduDay =2;
        Info.NewsFirstMomey = Convert.ToDouble(txtNewsFirstMomey.Text.Trim());
        Info.NewsSecondMomey = Convert.ToDouble(txtNewsSecondMomey.Text.Trim());
        Info.LinkFirstMomey = Convert.ToDouble(txtLinkFirstMomey.Text.Trim());
        Info.LinkSecondMomey = Convert.ToDouble(txtLinkSecondMomey.Text.Trim());
        Info.OurWebMomey = Convert.ToDouble(txtOurWebMomey.Text.Trim());
        Info.LockNumber = Convert.ToInt32(txtLockNumber.Text.Trim());
        bool bResult = new BisSysConfig().Update(Info);
        Common.sysConfig = null;
        Until.Alert(bResult?"提交成功!":"提交失败！");      
    }
}